<template>
    <div>
        <setHeader title="活动管理"></setHeader>
        <div class="content">
            <div class="main-activity_manage">
                <!-- <div class="emptyProduct" v-if="actives == ''" style="margin-top:0.6rem;">
                    <img src="../common/images/empty.png" alt="">
                    <p>暂无数据  ╮(￣▽￣)╭</p>
                </div> -->
                <div v-if="actives == ''" class="contentEmpty" style="margin-top: .2rem;margin-bottom: 0.8rem;">
                    <img src="../common/images/Disappointment.png" alt="">
                    <em>暂无查询结果</em>
                </div>
                <!-- 活动列表 -->
                <div class="active_item" style="padding-top: 0.2rem;" v-else>
                    <ul>
                        <li v-for="(activeitem, act) in actives" :key="act" class="clear" @click="activityClick(activeitem.id)">
                            <span class="active_list_img">
                                <img src="../common/images/cindex_19.jpg" v-if="activeitem.img == null">
                                <img :src="activeitem.img" alt="" v-else>
                            </span>
                            <p class="active_text"><em class="cur">热门</em>{{activeitem.title}}</p>
                            <p class="active_text">开始时间：{{activeitem.begin_time | dateFormat("yyyy-MM-dd")}}</p>
                            <p class="active_text"><span><sub>￥</sub><strong>{{Number(activeitem.price).toFixed(0)}}</strong>起</span></p>
                            <!-- <span>{{activeitem.apply_num}}人已经报名</span> -->
                        </li>
                    </ul>
                </div>
                <!-- 添加 -->
                <div class="main_tianjia" @click="activityInsertClick"  v-if="t_show">
                    <i class="iconfont icon-jia"></i>
                </div>
            </div>
        </div>
        <so-footer></so-footer>
    </div>
</template>

<script>
import setHeader from '../public/setHeader.vue';
import soFooter from '../components/footer-bar';
    export default {
        data() {
            return {
                actives: [],
                // path:"http://fc.x.e000.com",
                t_show:false,
                userInfo:'',
                /*actives: [
                    {
                        active_text: '无忧俱乐部九十八周庆全场办卡打6.6折，优惠多多。',
                        active_time: '2018-11-21',
                        active_money: '20',
                        active_people: '67人已经报名'
                    },
                    {
                        active_text: '无忧俱乐部九十八周庆全场办卡打6.6折，优惠多多。',
                        active_time: '2018-11-21',
                        active_money: '20',
                        active_people: '67人已经报名'
                    }
                ],*/
                cpId: ''
            }
        },
        mounted() {
            this.cpId = window.localStorage.getItem('cpId');
            this.userInfo = JSON.parse(window.localStorage.getItem('userInfo'));
            this.activitylist();
            this.u_type = this.$route.query.u_type;
            if(this.u_type == 1){
                this.t_show = true;
            }
        },
        methods: {
            activitylist() {
                let c_id = this.$route.query.cp_id;
                let userId = this.userInfo.uid;
                this.$fetch(this.$path + '/api.php/Activity/getActivityList', {c_id}).then((response) => {
                        console.log('活动管理', response)
                    if(response.code == 200) {
                        this.actives = response.data;
                        console.log('活动管理', response.data)
                    }
                })
            },
            activityClick(id) {
                if(this.u_type ==1){
                    this.$router.push({
                        path: '/userCenter/activityEditor',
                        query: {id: id}
                    })
                }else{
                    this.$router.push({
                        path: '/activityDetail',
                        query: {id: id}
                    })
                }
              
            },
            activityInsertClick() {
                this.$router.push({
                    path: '/userCenter/activityInsert'
                })
            },
        },
        components: {
            setHeader,
            soFooter
        }
    }
</script>

<style>

/* 添加 */
.main_tianjia {
    width: 1rem;
    height: 1rem;
    background-color: #e50838 !important;
    border-radius: 50%;
    margin-bottom: 0.4rem;
    margin: 0 auto;
    margin-top: 0.4rem;
}
.main_tianjia .icon-jia {
    font-size: 0.48rem;
    line-height: 1rem;
    vertical-align: text-top;
    text-align: center;
    color: #fff;
}

/* 活动为空 */
.main-activity_manage .emptyProduct {
  padding: 0 0 0.2rem;
  box-sizing: border-box;
}
.main-activity_manage .emptyProduct img {
  width: 1.56rem;
  height: 1.22rem;
  margin: 0 auto;
}
.main-activity_manage .emptyProduct p {
  font-size: 0.26rem;
  color: #999;
  text-align: center;
}


</style>